package com.hrbxlh.virtualization.websocket;

import com.hrbxlh.virtualization.service.ContainerService;
import com.hrbxlh.virtualization.support.SpringContextHolder;

import javax.websocket.OnClose;
import javax.websocket.OnOpen;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;

/**
 * 教师查看镜像或制作章节WebSocket
 *
 * @author cheer
 */
@ServerEndpoint(value = "/webSocket/image/{containerId}")
public class DesktopByImageWebSocket {

    private ContainerService containerService = SpringContextHolder.getBean(ContainerService.class);

    private Long containerId;

    @OnOpen
    public void onOpen(@PathParam("containerId") Long containerId) {
        this.containerId = containerId;
    }

    @OnClose
    public void onClose() {
        containerService.deleteContainerById(containerId);
    }

}
